{include file="public/layout" /}
<body class="laytp-container">
<div class="layui-card" id="search-form">
	<div class="layui-card-body">
  		<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-card layui-col-md12">
          <div class="layui-card-body" pad15>
						<div class="layui-form layui-col-md12 layui-form-search">
							<div class="layui-inline layuiadmin-input-useradmin">
								<label class="layui-form-label">姓名</label>
								<div class="layui-input-inline">
									<input type="text" name="realname" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline">
								<button class="layui-btn layuiadmin-btn-replys" lay-submit="" lay-filter="LAY-app-forumreply-search">
									<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
								</button>
							</div>
						</div>
						<div class="layui-col-md12">
							<table id="tabledata" lay-filter="tabledata"></table>
						</div>
          </div>
        </div>
    </div>
  </div>
	</div>
</div>
	<script type="text/html" id="nameTpl">
		<img src="{{d.pic}}" style="max-width:70px;float:left"/>
		<div style="float: left;width:200px;margin-left: 10px;white-space:normal;line-height:20px;">
			<div style="width:100%;padding-top:5px">{{# if(d.cid>0){ }}<span style="color:red">[{{d.cname}}] </span>{{# } }}{{d.name}}</div>
			<div style="padding-top:5px;font-size:12px">{{d.subname}}</div></div>
		</div>
	</script>
	<script>
  var table = layui.table;
	var datawhere = {};
  //数据表
  var tableIns = table.render({
    elem: '#tabledata'
    ,url: "{:url('index')}" //数据接口
    ,page: true //开启分页
    ,cols: [[ //表头
	  {type:"checkbox"},
	  {field: 'realname', title: '配送员姓名'},
	  {field: 'tel', title: '配送员电话'},
	  {field: 'nickname', title: '头像昵称',templet:function(d){
		  if(d.nickname){
			  return '<img src="'+d.headimg+'" style="width:40px;height:40px"/> '+ d.nickname
		  }
		  return '';
	  }},
	  {field: 'sort', title: '创建时间',templet:function(d){ return date('Y-m-d H:i',d.createtime)}},
	  {field: 'status', title: '状态',templet:function(d){
		  if(d.status==0){
			  return '<span style="color:red">已关闭</span>';
		  }else if(d.status==1){
			  return '<span style="color:green">已开启</span>';
		  }
	  }},
      {field: 'operation', title: '操作',templet: '<div><button class="layui-btn layui-btn-xs" onclick="choosepsuser(\'{{d.id}}\')">选择</button></div>',align:'center'}
    ]]
  });
	function choosepsuser(id){
		var index = layer.load();
		$.post("",{id:id},function(res){
			layer.close(index);
			window.parent.choosepeisonguser(res.data,"{$Request.param.args}");
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		})
	}
	//排序
	table.on('sort(tabledata)', function(obj){
		datawhere.field = obj.field;
		datawhere.order = obj.type;
		tableIns.reload({
			initSort: obj,
			where: datawhere
		});
	});
	//检索
	layui.form.on('submit(LAY-app-forumreply-search)', function(obj){
		var field = obj.field
		var olddatawhere = datawhere
		datawhere = field
		datawhere.field = olddatawhere.field
		datawhere.order = olddatawhere.order
		tableIns.reload({
			where: datawhere,
			page: {curr: 1}
		});
	})
	</script>
</body>
</html>